<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Config;
class ConfigController extends Controller
{
    //
    public function getConfig(Request $request)
    {
        $config=Config::get($request->input('cf_name'));

        $respond=array(
            'ret'=>200,
            'data'=>$config
        );
        return json_encode($respond);
    }
    public function setConfig(Request $request){
        if($request->input('only')){
            $res=Config::set($request->input('cf_name'),$request->input('cf_value'),true);
        }
        else{
            $res=Config::set($request->input('cf_name'),$request->input('cf_value'));
        }

        $respond=array(
            'ret'=>200,
            'data'=>[
                'status'=>$res
            ]
        );
        return json_encode($respond);
    }
}
